package com.wuwangfu.utils;

import java.io.InputStream;
import java.util.Properties;

/**
 * @Description：读取jar包里的资源文件：resource目录下的配置文件
 * @Author：jcshen
 * @Date：2023-07-02
 */
public class AnotherProperties {

    Properties properties;

    public synchronized Properties getKafkaProperties(){
        if (null !=properties){
            return properties;
        }
        //获取配置文件kafka.properties的配置
        Properties kafkaProperties = new Properties();

        try {
//        InputStream in = ClassLoader.getSystemResourceAsStream("kafka.propertie");
            InputStream in = this.getClass().getResourceAsStream("/kafka.properties");
            kafkaProperties.load(in);
            System.out.println("========"+kafkaProperties.getProperty("bootstrap.servers")+"========");
            System.out.println("========"+kafkaProperties.getProperty("ssl.truststore.location")+"========");
        } catch (Exception e) {
            //没有加载到文件，程序要考虑退出
            e.printStackTrace();
        }
        properties = kafkaProperties;
        return kafkaProperties;
    }
}
